#!/bin/bash
# send message to user

date +'%Y-%m-%d'
echo $1

if [ ! "$1" ]; then
	echo 'ERROR:Miss a username!'
	exit 0
fi

USER_FLAG=0
if who | grep -w "$1"; then
  USER_FLAG=1;
  write $1 <<< 'hello'
fi

if [ $USER_FLAG -eq 0 ]
then
  echo "ERROR:user $1 not found."
fi
